package com.ellricky.teacher.ui.mycourse.workjoin

import android.view.View
import com.ellricky.baselib.http.callback.ECallback
import com.ellricky.baselib.ui.base.BaseDetailActivity
import com.ellricky.teacher.API_WORK_JOIN_CANCEL
import com.ellricky.teacher.API_WORK_JOIN_DETAIL
import com.ellricky.teacher.R
import com.ellricky.teacher.WorkJoinDetailEntity
import kotlinx.android.synthetic.main.tc_activity_workjoin_detail.*

class WorkJoinDetailActivity : BaseDetailActivity() {

    override fun getChildContentLayout(): Int {
        return R.layout.tc_activity_workjoin_detail
    }


    override fun initUIView() {
        super.initUIView()
        mTvTitle.text = getString(R.string.tc_work_join_detail)
        btnCancel.setOnClickListener(this)

        loadDetail(id)

    }

    private fun loadDetail(id: String) {
        mPresenter.loadDetail(
                API_WORK_JOIN_DETAIL, id, object : ECallback<WorkJoinDetailEntity>(this) {
            override fun onSuccess(data: WorkJoinDetailEntity?, msg: String) {
                data?.let {
                    tvFromPerson.value = it.fromName
                    tvToPerson.value = it.toName
                    tvDate.value = it.changeToDate
                    tvDesc.text = it.workChangeInfo
                }
            }
        })

    }

    override fun onClickView(v: View?) {
        super.onClickView(v)
        when(v){
            btnCancel -> mPresenter.sendBackRequest(API_WORK_JOIN_CANCEL,id)
        }
    }
}
